import inherits from 'inherits'

import PropertiesActivator from 'bpmn-js-properties-panel/lib/PropertiesActivator'

// Require all properties you need from existing providers.
// In this case all available bpmn relevant properties without camunda extensions.
import processProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/ProcessProps'
// import eventProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/EventProps'
// import linkProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/LinkProps'
// import documentationProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/DocumentationProps'
import idProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/IdProps'
import nameProps from 'bpmn-js-properties-panel/lib/provider/bpmn/parts/NameProps'
// Require your custom property entries.
import spellProps from './parts/SpellProps'

// The general tab contains all bpmn relevant properties.
// The properties are organized in groups.
function createGeneralTabGroups (element, bpmnFactory, elementRegistry, translate) {
  const generalGroup = {
    id: 'general',
    // 文章标示
    label: '常规',
    // 内容数组
    entries: []
  }
  idProps(generalGroup, element, translate)
  nameProps(generalGroup, element, translate)
  processProps(generalGroup, element, translate)
  // 自定义常规tab的下拉框内容
  const blackMagicGroup = {
    id: 'black-magic',
    label: '实现方式',
    entries: []
  }
  spellProps(blackMagicGroup, element)

  // const detailsGroup = {
  //   id: 'details',
  //   label: 'Details',
  //   entries: []
  // };
  // linkProps(detailsGroup, element, translate);
  // eventProps(detailsGroup, element, bpmnFactory, elementRegistry, translate);

  // const documentationGroup = {
  //   id: 'documentation',
  //   label: 'Documentation',
  //   entries: []
  // };

  // documentationProps(documentationGroup, element, bpmnFactory, translate);
  // 展示常规模块的额
  return [
    generalGroup,
    blackMagicGroup
    // detailsGroup,
    // documentationGroup
  ]
}

// Create the custom magic tab
// function createMagicTabGroups (element, elementRegistry) {
//   // Create a group called "Black Magic".
//   var blackMagicGroup = {
//     id: 'black-magic',
//     label: '实现方式',
//     entries: []
//   }
//   // Add the spell props to the black magic group.
//   spellProps(blackMagicGroup, element)
//   return [
//     blackMagicGroup
//   ]
// }

export default function MagicPropertiesProvider (eventBus, bpmnFactory, elementRegistry, translate) {
  PropertiesActivator.call(this, eventBus)
  this.getTabs = function (element) {
    const generalTab = {
      id: 'general',
      label: '常规',
      groups: createGeneralTabGroups(element, bpmnFactory, elementRegistry, translate)
    }
    // The "magic" tab
    // const magicTab = {
    //   id: 'magic',
    //   label: '实现方式',
    //   groups: createMagicTabGroups(element, elementRegistry)
    // }
    // Show 常规 + "自定义" tab
    return [
      generalTab
      // magicTab
    ]
  }
}

inherits(MagicPropertiesProvider, PropertiesActivator)
